package ui;

import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.UIManager;

import util.Menu;

public class MainWindow extends JFrame
{
        private static final long serialVersionUID = 1L;

        private static MainWindow instance = null;

        private JPanel redBar;

        private JMenuBar menu;

        private Menu menuBar;
        
        public MainWindow()
        {
                addWindowListener(
                                new WindowAdapter() 
                                {
                                        public void windowClosing(WindowEvent we) 
                                        { 
                                                System.exit(0);
                                        }
                                }
                                );
                
                setTitle("Vaizdine Reklama");

                menuBar = Menu.getInstance();

                menu = menuBar.makeJMenuBar();
                                
                setJMenuBar(menu);

                redBar = new JPanel();
                redBar.setBackground(new Color(165,42,42));

                setContentPane(redBar);
                                
                redBar.setLayout(null);
                
        }


        public static MainWindow getInstance()
        {
                if(instance == null)
                        instance = new MainWindow();

                return instance;
        }
        
        public static void main(String[] args)
        {
                try 
                {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                        
                }
                catch(Exception e)
                {
                        System.out.println("[ERROR] Main Window cannot load");
                        e.printStackTrace();
                }
        }
}